﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _6.SortNamesByFile
{
    class SortNamesByFile
    {
        static List<string> names = new List<string>();

        static void Main()
        {
            StreamReader reader = new StreamReader(@"..\..\UnsortedNames.txt");
            using (reader)
            {
                while (reader.EndOfStream != true)
                {

                    string line = reader.ReadLine();
                    if (line != null)
                    {
                        names.Add(line);
                    }
                }
            }
            names.Sort();
            StreamWriter writer = new StreamWriter(@"..\..\SortedNames.txt");
            using (writer)
            {
                foreach (string name in names)
                {
                    writer.WriteLine(name);
                }
            }
        }
    }
}
